package com.corner.model.cornerservice.domain;

import android.os.Parcel;
import android.os.Parcelable;

import com.google.gson.annotations.Expose;

public class BaseBean implements Parcelable {
    public static final String UPDATED_AT = "updateAt";
    @Expose
    private Long objectId;
    @Expose
    private Long createAt;
    @Expose
    private Long updateAt;
    @Expose
    private Boolean isValid;

    public BaseBean() {
    }

    protected BaseBean(Parcel in) {
        this.objectId = (Long) in.readValue(Long.class.getClassLoader());
        this.createAt = (Long) in.readValue(Long.class.getClassLoader());
        this.updateAt = (Long) in.readValue(Long.class.getClassLoader());
        this.isValid = (Boolean) in.readValue(Boolean.class.getClassLoader());
    }

    public static <T extends BaseBean> T createWithoutData(Long objectId, Class<T> t) {
        T obj = null;
        try {
            obj = t.newInstance();
            obj.setObjectId(objectId);

        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        }
        return obj;
    }

    public Long getObjectId() {
        return objectId;
    }

    public void setObjectId(Long objectId) {
        this.objectId = objectId;
    }

    public Long getCreateAt() {
        return createAt;
    }

    public void setCreateAt(Long createAt) {
        this.createAt = createAt;
    }

    public Long getUpdateAt() {
        return updateAt;
    }

    public void setUpdateAt(Long updateAt) {
        this.updateAt = updateAt;
    }

    public Boolean getIsValid() {
        return isValid;
    }

    public void setIsValid(Boolean isValid) {
        this.isValid = isValid;
    }

    /*********************************************************************/
    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeValue(this.objectId);
        dest.writeValue(this.createAt);
        dest.writeValue(this.updateAt);
        dest.writeValue(this.isValid);
    }

}
